home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / dist / libiberty / insque.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-24  |  1.6 KB  |  72 lines

  1. /* insque(3C) routines
  2.    Copyright (C) 1991 Free Software Foundation, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. /*
  19.  
  20. NAME
  21.  
  22.     insque, remque -- insert, remove an element from a queue
  23.  
  24. SYNOPSIS
  25.  
  26.     struct qelem {
  27.       struct qelem *q_forw;
  28.       struct qelem *q_back;
  29.       char q_data[];
  30.     };
  31.  
  32.     void insque (struct qelem *elem, struct qelem *pred)
  33.  
  34.     void remque (struct qelem *elem)
  35.  
  36. DESCRIPTION
  37.  
  38.     Routines to manipulate queues built from doubly linked lists.
  39.     The insque routine inserts ELEM in the queue immediately after
  40.     PRED.  The remque routine removes ELEM from its containing queue.
  41.  
  42. BUGS
  43.  
  44. */
  45.  
  46.  
  47. struct qelem {
  48.   struct qelem *q_forw;
  49.   struct qelem *q_back;
  50. };
  51.  
  52.  
  53. void
  54. insque (elem, pred)
  55.   struct qelem *elem;
  56.   struct qelem *pred;
  57. {
  58.   elem -> q_forw = pred -> q_forw;
  59.   pred -> q_forw -> q_back = elem;
  60.   elem -> q_back = pred;
  61.   pred -> q_forw = elem;
  62. }
  63.  
  64.  
  65. void
  66. remque (elem)
  67.   struct qelem *elem;
  68. {
  69.   elem -> q_forw -> q_back = elem -> q_back;
  70.   elem -> q_back -> q_forw = elem -> q_forw;
  71. }
  72.